

package cn.sc.allinpay.allfavour.module.printer;

import android.text.TextUtils;

import com.landicorp.android.eptapi.device.Printer;

/**
 * 线上加油小票摘要打印
 * author：pany
 * on 2017/11/3 11:48
 */
public class OilPrinter extends BasePrinter {

    public OilPrinter(PrintData data) {
        super(data);
    }

    @Override
    protected void printBody(Printer printer, PrintData data) throws Exception {
        printer.setFormat(FormatStyle.createNormalFont());
        printer.println("订 单 号：");
        printer.println(data.getOrderId());
        printer.println("交易类型：用户快捷加油");
        printer.println("油品号：" + data.getOilName());
        printer.println("交易时间：" + data.getTime());
        printer.println("订单金额：￥" + data.getAmt());
        if (!TextUtils.isEmpty(data.getTrsAmt())) {
            printer.println("线上支付金额：￥" + data.getTrsAmt());
        }
        if (!TextUtils.isEmpty(data.getDisRightsAmt()) && !data.getDisRightsAmt().equals("0.00")) {
            printer.println("会员优惠金额：￥" + data.getDisRightsAmt() + "元");
        }
        if (!TextUtils.isEmpty(data.getDisCouponAmt()) && !data.getDisCouponAmt().equals("0.00")) {
            printer.println("卡券抵扣金额：￥" + data.getDisCouponAmt() + "元");
        }
        if (!TextUtils.isEmpty(data.getDisEWalletAmt()) && !data.getDisEWalletAmt().equals("0.00")) {
            printer.println("钱包支付金额：￥" + data.getDisEWalletAmt() + "元");
        }
        printer.feedLine(2);
    }

    @Override
    protected void printFooter(Printer printer, PrintData data) throws Exception {
        printer.feedLine(4);
    }

    @Override
    protected void printHeader(Printer printer, PrintData data) throws Exception {
        printer.feedLine(1);
    }
}
